package April._22.work3;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class CopyFile implements Runnable{
    FileReader in=null;FileWriter out=null;
    public void mutilCopy() throws IOException {
        char[] chars = new char[1024];
        int read;
        while((read=in.read(chars))!=-1){
            out.write(chars,0,read);
        }
        if(in!=null){
            in.close();
        }
        if(out!=null){
            out.close();
        }
    }


    @Override
    public void run() {
        try {
            mutilCopy();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public CopyFile(FileReader in, FileWriter out) {
        this.in = in;
        this.out = out;
    }
}
